﻿using AvalonDock;
using System.Linq;
using System.Windows;
using Prism.Unity;
using AvalonDock.Layout;
using System.Diagnostics;
using FrameWork.Core.Infrastructure;
using log4net;
using System.Runtime.CompilerServices;
using Unity;
using Microsoft.VisualBasic.Logging;
using System;

namespace AncheStart
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        [Unity.Dependency]
        public ILog Log4Net { get; set; }

        #region ___字段___

        private Prism.Ioc.IContainerExtension m_Container;

        #endregion ___字段___

        #region ___构造函数___

        public MainWindow(Prism.Ioc.IContainerExtension container)
        {
            InitializeComponent();
            m_Container = container;
        }

        #endregion ___构造函数___

        #region ___加载完成___

        /// <summary>
        /// 页面加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NbWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var unityExtension = m_Container as UnityContainerExtension;
            ////////////////初始化系统//////////////
            EngineContext.Initialize(false, new UnityContainerExtension(unityExtension.Instance));
            //Console.WriteLine("启动成功");
        }

        #endregion ___加载完成___

        private void myWindow_Unloaded(object sender, RoutedEventArgs e)
        {
        }

        private void myWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // 弹窗提示是否确定要退出
            MessageBoxResult result = MessageBox.Show("确定要退出充放电上位机主程序吗？", "上位机主程序退出提示", MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.Cancel);
    
            if (result == MessageBoxResult.Cancel)
            {
                e.Cancel = true; // 中断点击事件
            }
        }

        private void myWindow_ContextMenuClosing(object sender, System.Windows.Controls.ContextMenuEventArgs e)
        {
        }

        private void myWindow_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
        {

        }
    }
}